home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 016a / unique.zip / UNIQUE.BAT
DOS Batch File  |  1991-10-16  |  763b  |  32 lines

  1. :: unique.btm
  2. :: 1991-07-11
  3. :: Marc Thibault 71441,2226
  4.  
  5. ::    Outputs a unique filename in form MoDaHrNn.Ext 
  6. :: Input:
  7. ::    %1 may be up to 3 chars used as Extension
  8.  
  9. :: Usage:
  10. ::  The following sets 'var' to a unique filename, in the current 
  11. ::  directory, with 'ext' as the extension.
  12.  
  13. ::     UNIQUE ext | INPUT %%var
  14.  
  15. :: -------------------------------------------------------------------------        
  16. :: c is 2-digit index, initialized at current minute 
  17. :: e is 6-digit current month.day.hour
  18. :: f is constructed file name
  19.  
  20.     setlocal
  21.     set c=%@substr[%_time,3,2]
  22.     set e=%@substr[%_date,0,2]%@substr[%_date,3,2]%@substr[%_time,0,2]
  23.  
  24. :loop 
  25.     set f=%e%%c.%1
  26.     set c=%@substr[00%@eval[1+%c],1,-2]
  27.     if exist %f goto loop
  28.     
  29.     echo %f
  30.     endlocal
  31.  
  32.